package com.gisuni.sddc.platformManager.controller;

import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.GET;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.POST;
import org.nutz.mvc.annotation.Param;

import com.gisuni.sddc.platformManager.model.Organization;
import com.gisuni.sddc.platformManager.model.Response;
import com.gisuni.sddc.platformManager.model.Tree;
import com.gisuni.sddc.platformManager.service.LogService;
import com.gisuni.sddc.platformManager.service.OrganizationService;
import com.gisuni.sddc.util.StringUtil;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@IocBean(singleton = false)
@At("/client/backgroundManagement/logController")
public class LogController  {

	private Log log = Logs.getLog(UserController.class);
	
	@Inject
    private LogService logService;
	
 

	@At("/dataGrid")
	@GET
	@POST
	@Ok("raw:json") 
    public Object findGrid(@Param("page") int page, @Param("rows") int rows,HttpServletRequest request) {
         Object r = null;
         try{
        	 Response res = logService.findGrid(page,rows,request);
        	 r = res.toJSONObject(res);
         }catch(Exception e){
        	 log.error(e.getMessage());
         }
         return r;
    }

	/**
	 * 导出Excel
	 * @param departmentType
	 * @param projectType
	 * @param startdate
	 * @param enddate
	 * @param response
	 */
	@At("/exportLogExcel")
	@POST
	@GET
	public void exportlandSpecialdataExcel(HttpServletRequest request,HttpServletResponse response) {
		try {
			logService.exportLogExcel(request,response);
		} catch (Exception e) {
			e.printStackTrace();
			log.error(e.getMessage());
		}
	}
//
//	@At("/delete")
//	@GET
//	@POST
//	@Ok("json")
//    public Object delete(String id) {
//		Response res = new Response();
//		res.setSuccess(false);
//		try {
//			res =  organizationService.deleteOrganizationById(id);
//		} catch (Exception e) {
//			log.error(e.getMessage());
//		}
//		return res;
//    }
}
